package com.coreservlets.jsf.ss11;

import javax.faces.bean.ManagedBean;

import com.coreservlets.jsf.ss10.Person;

@ManagedBean
public class Person5 extends Person {

	@Override
	public String doRegistration()
	{
		if( isAnyEmpty( getFirstName(), getLastName(), getEmailAddress() ) )
		{
			return( "missing-input");
		}
		else
		{
			return( "confirm-registration");
		}
	}
	
	private boolean isAnyEmpty( String... values )
	{
		for( String value : values )
		{
			if( isEmpty( value ) )
			{
				return( true );
			}
		}
		
		return( false );
	}
	
	private boolean isEmpty( String value )
	{
		return( ( value == null ) || ( value.trim().length() == 0 ));
	}
}
